﻿using AspectCore.DynamicProxy;

namespace JoJoC_AOP.AOPS
{
    /// <summary>
    /// MyServiceAop
    /// 实现将Show1() 写入到 Show() 当中
    /// </summary>
    public class MyServiceAop : AbstractInterceptorAttribute
    {
        public override async Task Invoke(AspectContext context, AspectDelegate next)
        {
            Show1();
            await next(context);

            // 动态的插入Show2()方法
            Show2();
            
        }

        /// <summary>
        /// 定义Show1方法
        /// </summary>
        public void Show1()
        {
            Console.WriteLine("AOP开始执行！");
        }

        /// <summary>
        /// 定义Show2方法
        /// </summary>
        public void Show2()
        {
            Console.WriteLine("AOP结束执行！");
        }
    }
}
